<template>
  <el-card>
    <el-tabs>
      <div class="app-container">
        <el-form ref="form" :model="form" :rules="rules" label-width="150px">
          <el-form-item label="支付编号" prop="withdrawOrderNo">
            <el-input v-model="form.withdrawOrderNo" readonly/>
          </el-form-item>
          <el-form-item label="用户姓名" prop="userName">
            <el-input v-model="form.userName" readonly/>
          </el-form-item>
          <el-form-item label="手机号码" prop="userPhone">
            <el-input v-model="form.userPhone" readonly/>
          </el-form-item>
          <el-form-item label="收款人身份证号" prop="identityMark">
            <el-input v-model="form.identityMark" readonly/>
          </el-form-item>
          <el-form-item label="银行卡号" prop="bankCardMark">
            <el-input v-model="form.bankCardMark" readonly/>
          </el-form-item>
          <el-form-item label="银行名称" prop="bankName">
            <el-input v-model="form.bankName" readonly/>
          </el-form-item>
          <el-form-item label="支行名称" prop="subBranch">
            <el-input v-model="form.subBranch" readonly/>
          </el-form-item>
          <el-form-item label="申请金额" prop="transAmount">
            <el-input v-model="form.transAmount" readonly/>
          </el-form-item>
          <el-form-item label="申请时间" prop="createTime">
            <el-input v-model="form.createTime" readonly/>
          </el-form-item>
          <el-form-item label="到账金额" prop="withdrawAmount">
            <el-input v-model="form.withdrawAmount" readonly/>
          </el-form-item>
            <el-form-item label="审核状态" prop="checkStatusShow">
              <el-input v-model="form.checkStatusShow" readonly/>
            </el-form-item>
          <el-form-item label="审核时间" prop="checkStatusTime">
              <el-input v-model="form.checkStatusTime" readonly/>
          </el-form-item>
          <el-form-item label="支付状态" prop="withdrawStatus">
            <el-input v-model="form.withdrawStatusShow" readonly/>
          </el-form-item>
          <el-form-item label="支付时间" prop="withdrawStatusTime">
              <el-input v-model="form.withdrawStatusTime" readonly/>
          </el-form-item>
          <el-form-item style="text-align: center;margin-left:-100px;margin-top:10px;">
            <el-button @click="close()">返回</el-button>
          </el-form-item>
        </el-form>
      </div>
    </el-tabs>
  </el-card>
</template>

<script>
import {getTUserDefaultInfo, addTUserDefaultInfo, updateTUserDefaultInfo, exportTUserDefaultInfo } from "@/api/pos/TUserDefaultInfo";

export default {
  name: "defaultDetail",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 导出遮罩层
      exportLoading: false,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 用户出入账信息表格数据
      TUserDefaultInfoList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      form: {
        pageNum: 1,
        pageSize: 10,
        withdrawOrderNo: null,
        userName: null,
        userPhone: null,
        identityMark: null,
        bankCardMark: null,
        bankName: null,
        subBranch: null,
        transAmount: null,
        withdrawAmount: null,
        withdrawAmount: null,
        checkStatusShow: null,
        checkStatusTime: null,
        withdrawStatusShow: null,
        withdrawStatusTime: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    const id = this.$route.query && this.$route.query.id;
    getTUserDefaultInfo(id).then(response => {
      this.form = response.data;
      this.open = true;
      this.title = "修改用户出入账信息";
    });
  },
  methods: {
    /** 查询用户出入账信息列表 */
    /*getList() {
      this.loading = true;
      listTUserDefaultInfo(this.queryParams).then(response => {
        this.TUserDefaultInfoList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },*/
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    /** 关闭按钮 */
    close() {
      this.$store.dispatch("tagsView/delView", this.$route);
      this.$router.push({path: "/userManage/TUserDefaultInfo", query: {t: Date.now(), pageNum: this.$route.query.pageNum}})
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        userId: null,
        transType: null,
        transAmount: null,
        transOperType: null,
        goldType: null,
        brandId: null,
        orderId: null,
        createTime: null,
        updateUserId: null,
        updateTime: null,
        checkStatus: "0",
        checkStatusUserId: null,
        checkStatusTime: null,
        checkStatusDescribe: null,
        serviceChargeAmount: null,
        withdrawAmount: null,
        refereesUserId: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getTUserDefaultInfo(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改用户出入账信息";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateTUserDefaultInfo(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addTUserDefaultInfo(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams;
      this.$modal.confirm('是否确认导出所有用户出入账信息数据项？').then(() => {
        this.exportLoading = true;
        return exportTUserDefaultInfo(queryParams);
      }).then(response => {
        this.$download.name(response.msg);
        this.exportLoading = false;
      }).catch(() => {});
    }
  }
};
</script>
